# -*- coding: utf-8 -*-
'''
Author: Zhuangyu
Date: 2022-03-30 15:14:42
LastEditTime: 2022-11-25 22:54:08
'''



from __future__ import print_function, division
import numpy as np
from casadi import *

# Contains space, time and soil parameters used to set up
# the 1D and 3D Richards equation models.
# These parameters may be modified to adapt both models
# to a specific field. 

def circular_parameters():
    #Spatial parameters
    Hr=50    #The radius of the field
    Ht=2*np.pi  #The angle of rotation of the pivot
    Ht=2*np.pi  #The angle of rotation of the pivot    
    Hz=0.30  #The depth of the soil
    Nr=6     #Number of nodes in the r-direction
    Nt=40    #Number of nodes in the theta-direction
    Nz=16    #Number of nodes in the z-direction
    dr=Hr/(Nr-1) #distance between nodes in the r-direction
    dt=Ht/Nt     #angle between nodes in the theta-direction
    dz=Hz/(Nz-1) #distance between nodes in the z-direction
    Na=Nz
    Np=Na+Nz
    N_obs=16
    return Nr,Nt,Nz,dr,dt,dz,Np,Na,Np,N_obs,Hz

def time_parameters():
    #Temporal parameters in seconds
    # DeltaT =6*60 
    DeltaT = 60
    Tsim=1*4*6*60*60
    # Tsim=1*4*6*60*60*2
    # Tsim=1*4*8*60
    # Tsim=1*4*60*60*5
    Nsim = int(Tsim/DeltaT) #Total number of time steps
    return DeltaT,Nsim

def cmatrix_single(Nx):
    CMatrix = DM.eye(Nx) #the c-matrix
    return CMatrix

#Soil hydraulic parameters for Loamy soil
def Loam():
  pars={}
  pars['thetaR']=0.078
  pars['thetaS']=0.43
  pars['alpha']=3.6
  pars['n']=1.56
  pars['m']=1-1/pars['n']
  pars['Ks']=0.00000288889
  pars['neta']=0.5
  pars['Ss']=0.00001
  return pars

# Creating the coordinates which identify each node (r,theta,z).
def creating_coordinates(Nz,Nt,Nr):
    coordinates=[]
    for k in range(Nz):
        for j in range(Nt):
            for i in range(Nr):
                y=[i,j,k]
                coordinates.append(y)
    return coordinates




